/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2023.
 * Description: notifier: add task exit notifier chain
 * Author: liuchao
 * Create: 2020-05-08
 */

#ifndef _TASK_EXIT_NOTIFIER_H_
#define _TASK_EXIT_NOTIFIER_H_

#ifdef CONFIG_EULEROS_TASK_EXIT_NOTIFIER_CHAIN

#include <linux/notifier.h>

/**
 *	task_exit_notifier_register - Add notifier to a blocking notifier chain
 *	@nb: New entry in notifier chain
 *
 *	Adds a notifier to a blocking notifier chain.
 *	If multiple exceptions occur concurrently, kernel fault notifier will
 *	ensure that notification only once.
 *
 *	Returns zero on success or %-EINVAL on failure.
 */
int task_exit_notifier_register(struct notifier_block *nb);

/**
 *	task_exit_notifier_unregister - Remove notifier from a blocking notifier chain
 *	@nb: Entry to remove from notifier chain
 *
 *	Removes a notifier from a blocking notifier chain.
 *
 *	Returns zero on success or %-ENOENT or %-EINVAL on failure.
 */
int task_exit_notifier_unregister(struct notifier_block *nb);
void last_task_exit(struct task_struct *task);
extern int __task_exit;
int task_exit_notifier_enabled(void);

#else
static inline void last_task_exit(struct task_struct *task) {};

#endif /* CONFIG_EULEROS_TASK_EXIT_NOTIFIER_CHAIN */

#endif /* _TASK_EXIT_NOTIFIER_H_ */
